#!/usr/bin/env python
# -*- coding: utf-8 -*-

import time
import threading
from loguru import logger

from PyQt5.QtCore import QThread, pyqtSignal

# not used now
class CallMatlab(QThread):

    call_matlab_end = pyqtSignal(str)
    event = threading.Event()

    def __init__(self, callMatlabFunc):
        super().__init__()
        self.call_matlab = callMatlabFunc
    
    def run(self):
        if self.call_matlab is None:
            logger.warning("callMatlabFunc is not set.")
            self.call_matlab_end.emit("")
            return
        
        window_name = "window"
        
        try:
            window_name = self.call_matlab()
            self.call_matlab_end.emit(window_name)
        except:
            logger.exception("callMatlabFunc run failed. ")
            return
        
        self.event.wait()
        logger.debug("callMatlabFunc runs end.")

